format-string Questions

6

Solved

I was reading about vulnerabilities in code and came across this Format-String Vulnerability. Wikipedia says: Format string bugs most commonly appear when a programmer wishes to print a strin...
Dunham asked 18/9, 2011 at 5:17

12

Solved

What is the use of the %n format specifier in C? Could anyone explain with an example?
Taam asked 3/8, 2010 at 22:11

3

Solved

Background Suppose I use SpannableStringBuilder to append multiple stuff into it, and one of them is string that I format from the strings.xml file, which has a span inside: SpannableStringBuilde...

4

Solved

I would like to format an integer as a percent without it multiplying by 100 as shown here. Because my source is an int, dividing it first by 100 is not a valid option. Is this possible? [DisplayFo...
Humanitarianism asked 12/5, 2011 at 20:11

2

Solved

I am trying to develop a format string to pass to git log --pretty so that each log entry ends in a full commit message, yet each log entry is separated by exactly one empty line. The problem is th...
Scornful asked 19/9, 2019 at 17:23

4

Solved

I have seen these two parameters in a C example in a C book, but the author didn't elaborate what the difference between the two is. I know that %f specifies that a float should take its place. I h...
Paxwax asked 16/9, 2014 at 4:46

2

Solved

I am reading about and trying to learn format string vulnerabilities. I have a vulnerable function and I understand the gist of what I have to do with my format string. Basically, this is what I w...
Tricky asked 3/10, 2013 at 18:38

5

Solved

I wrote a small example of the issue for everybody to see what's going on using Python 2.7 and Django 1.10.8 # -*- coding: utf-8 -*- from __future__ import absolute_import, division, unicode_liter...
Airy asked 13/10, 2017 at 9:38

13

Solved

How do you escape the % sign when using printf in C? printf("hello\%"); /* not like this */
Haruspicy asked 7/12, 2009 at 14:2

3

Solved

In my app I find myself using stftime a lot, and mostly with 2 strings formats - ("%d/%m/%Y") and ("%H:%M") Instead of writing the string each time, I want to store those strings in some global va...
Tymothy asked 18/1, 2017 at 9:33

4

Solved

I would like to be able to get the format string from a DateTime string. e.g. "2012-12-08 15:00:00" => "yyyy-MM-dd HH:mm:ss" "2013/30/01 16:00" => "yyyy/dd...
Taxidermy asked 19/9, 2013 at 10:4

2

I'm taking a security course which needs us to do format string attack on an unix virtual machine. The vulnerability is a format string using command line argument. My question is how can I write ...
Alpinist asked 31/1, 2011 at 19:33

3

Solved

I want to print out a variable of type size_t in C but it appears that size_t is aliased to different variable types on different architectures. For example, on one machine (64-bit) the following c...

4

Solved

I want to have a tooltip hover highlight thingy in jqplot. The problem is that I want it to give more detail then on the axes. So the formatter should be different. I can't get it to display the se...
Suribachi asked 14/5, 2012 at 15:58

2

Solved

Using sprintf and the general syntax "%A.B" I can do this: double a = 0.0000005l; char myNumber[50]; sprintf(myNumber,"%.2lf",a); Can I set A and B dynamically in the format string?
Zootomy asked 23/6, 2015 at 9:6

2

Examples: "Something %d" and "Something else %d" // Compatible "Something %d" and "Something else %f" // Not Compatible "Something %d" and "Something %d else %d" // Not Compatible "Something %d an...
Triphammer asked 9/3, 2015 at 16:51

1

Solved

I'm currently writing a short program that does frequency analysis. However, there's one line that is bothering me: "{0[0]} | " + "[]" * num_occurrences + " Total: {0[1]!s}" Is there a way in Py...
Hindustani asked 28/3, 2015 at 19:42

4

Solved

When printing a hexadecimal value (%x) and an address (%p), the format is slightly different. The printed value does not start with 0x in the case of a hexadecimal value: int main() { int x = 0x1...
Telemachus asked 25/2, 2015 at 10:10

1

Solved

Assume I have the following code: #include <stdio.h> #include <stdlib.h> #include <fcntl.h> int num1 = 0; int main(int argc, char **argv){ double num2; int *ptr = &num1; ...
Agonist asked 19/11, 2014 at 14:5

3

Solved

I'm working on a format-string vulnerability lab, where we're given the following code: #define SECRET1 0x44 #define SECRET2 0x55 int main(int argc, char *argv[]) { char user_input[100]; int *...
Florinda asked 17/4, 2013 at 18:27

2

Lately, I noticed a strange case I would like to verify: By SUS, for %n in a format string, the respective int will be set to the-amount-of-bytes-written-to-the-output. Additionally, for snprintf(...
Indissoluble asked 28/8, 2014 at 18:58

1

Solved

I'm interfacing with a really old system and the file I need to generate needs a field that is a formed from a string but needs to be exactly 15 in width. I want something like this: val companyN...
Gastrectomy asked 13/3, 2013 at 1:6

1

I have a small C program to be exploited. And I also understood the logic behind the attack to be performed. However, as much as I try, it is just not working for me. #include <stdio.h> #inc...
Pilose asked 16/11, 2012 at 2:27

1

Solved

The following program has undefined behavior: #include <stdio.h> int main(void) { unsigned int x = -100; // This is fine, becomes UINT_MAX - 100 printf("%d\n", x); // This is undefined be...
Twoway asked 3/7, 2012 at 2:39

2

Solved

I want to get the arguments passed to a function. for example, if I have the call printf("%d%d", i, j); the output should be %d%dij I am able to get to function calls using VisitCallExpr(...
Erinerina asked 7/3, 2012 at 19:32

© 2022 - 2024 — McMap. All rights reserved.